<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8"></meta>
		<title>四六级在线报名系统</title>
		<meta name="renderer" content="webkit"></meta>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"></meta>
		<link rel="stylesheet" href="layui/css/layui.css" media="all"></link>
	</head>
 <script src="layui/layui.js"></script>
<body class="layui-layout-body">
		<script src="http://code.jquery.com/jquery-latest.js"></script>
 
		<link rel="stylesheet" href="css/login.css" media="all"></link>
		<link rel="stylesheet" href="css/admin.css" media="all"></link>
		<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
			<script src="layui/layui.js"></script>
		
			<div class="layadmin-user-login-main">
				<div class="layadmin-user-login-box layadmin-user-login-header">
					<h2>四六级在线报名系统</h2>
					<p>四六级用户登录</p>
				</div>
				<div class="layadmin-user-login-box layadmin-user-login-body layui-form">
					<form id="useLogin" class="layui-form" method="post" action="">
						<div class="layui-form-item">
							<label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
							<input type="text"   id="txtname" lay-verify="required" placeholder="用户名" class="layui-input"/>
						</div>
						<div class="layui-form-item">
							<label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
							<input type="password"   id="txtpassword" lay-verify="required" placeholder="密码" class="layui-input"/>
						</div>
						 	<div class="layui-form-item">
							<div class="layui-row">
								<div class="layui-col-xs7">
									<label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
									<input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required" placeholder="图形验证码" class="layui-input"/>
								</div>
								<div class="layui-col-xs5">
            <div style="margin-left: 10px;">
              <img src="https://www.oschina.net/action/user/captcha" class="layadmin-user-login-codeimg" id="LAY-user-get-vercode"/>
            </div>
          </div> 
          </div>
          </div>
          

						<div class="layui-form-item" style="margin-bottom: 20px;">
							<input type="checkbox" name="remember" lay-skin="primary" title="记住密码"/>
							<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>记住密码</span><i class="layui-icon"></i></div>
							<a lay-href="/user/forget" class="layadmin-user-jump-change layadmin-link" style="margin-top: 7px;">忘记密码？</a>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
							<button id="loginBtn" class="layui-btn " lay-submit="" lay-filter="login">登录</button>
								<button class="layui-btn layui-btn-primary" type="reset">重置</button>
								
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script src="layui/layui.js"></script>
		<script src="http://code.jquery.com/jquery-latest.js"></script>
 <script>
	$(function() {
		layui.use(['form', 'layer'], function() {
			var form = layui.form;
			var layer = layui.layer;
			//监控提交

			form.on("submit(login)", function() {
				login();
				return false;
			});
		})
	})

	function login() {	
		$.ajax({
			url: "Admin/login",
			contentType: "application/json; charset=utf-8",  
		    dataType: "json",  
			type: "POST",
			async: true,
		    timeout: 50000,
			data: JSON.stringify({   
               "name": $("#txtname").val(),
                 "password": $("#txtpassword").val() 				 
	        }),
			success: function(data) {
				 
				if(data.code == "1000")
					{
					layer.alert("登录成功", function() {
						layer.closeAll();
						var index = layer.load(1, {
                             shade: [0.1,'#fff'] //0.1透明度的白色背景
});
						localStorage.setItem("admin",JSON.stringify(data.obj));
						window.location.href="adminmain.html";  
					});
				} else {
				  layer.alert(data.message);
				  $("#txtname").val();
				  $("#txtpassword").val();
				}
			} ,
			  error: function() {
				layer.alert("操作请求错误，请您稍后再试", function() {
					layer.closeAll();
				});
			}  
		});
	}
 </script>
	</body>
</html>